package pers.zw.study.servlet;

import sun.plugin2.message.Message;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Enumeration;

/**
 * getParameterNames()获取不全
 */
@WebServlet(name = "ServletRequestDemo4", urlPatterns = "/ServletRequestDemo4")
public class ServletRequestDemo4 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setHeader("content-type", "text/html; charset=UTF-8");
        Enumeration<String> formParams = request.getParameterNames();
        while (formParams.hasMoreElements()) {
            String name = formParams.nextElement();
            String value = request.getParameter(name);

            response.getWriter().write(MessageFormat.format("{0}={1}", name, value) + "<br/>");
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


    }
}
